package SetCompany;

import java.util.ArrayList;
import java.util.*;

public class Company {
    //公司有公司名称，注册地址，电话，经营范围等属性
    private String comName = "合肥科海";
    private String comAddres = "包河区";
    private String comTel = "13965335332";
    private String comBusiness = "房产中介";//经营范围
    int pos = 0;
    Set<People> set = new HashSet<>();

    //private String name;
    //    private int age;
    //    private String sex;
    //    private String work;
    //    private int money;
    //    private String  id;

    //添加员工
    public void addPeople(String name, int age, String sex, String work, int money, String id) {

        if (pos >= set.size()) {
            System.out.println("公司满员了");
        }
        for (People p :
                set) {
            if (p.getId().equals(id)) {
                System.out.println("工号相同,不可添加");
                return;
            }
            
        }
        set.add(new People(name, age, sex, work, money, id));
        System.out.println("添加成功");
        pos++;
    }

    //查看公司人数
    public void seePeople() {
        System.out.println("公司现有"+pos + "人");

    }

    //输出人口
    public void printPeo() {
        for (People p :
                set) {
            System.out.println(set);
            
        }
    }

    //辞退员工
    public void fired(String id) {
        for (People people:set){
            if (people.getId().equals(id)){
                set.remove(people);
                System.out.println("删除成功");
                return;
            }
        }
        System.out.println("删除失败，工号输入错误");
        return;
    }

    //查找工资最高的员工
    public void max() {
        Iterator<People> iterator = set.iterator();
        People people = iterator.next();
        while (iterator.hasNext()){
            if (people.getMoney()<=iterator.next().getMoney());
            people=iterator.next();
        }
        System.out.println(people);
    }

    






}
